package day240123

import "fmt"

func M测试切片() {
	s := make([]string, 0) //make切片，初始长度为0,容量也为0
	s = append(s, "1")
	s = append(s, "2")
	s = append(s, "3")
	fmt.Println(len(s), cap(s)) //3 3
	//cap(s)	是容量
	// 扩容机制，当切片长度超过容量时，会自动扩容，扩容的策略是原来的2倍
	s = append(s, "4", "5", "6", "7", "8", "9")
	fmt.Println(len(s), cap(s))
}
